<template>
    <view class="bg-content">
        <div v-if="isShow">
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderNumber :chartsData="chartsData.statisticOrderNumber"></statisticOrderNumber>
            </div>
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderSaleMoney :chartsData="chartsData.statisticOrderSaleMoney"></statisticOrderSaleMoney>
            </div>
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderNumber24Hours :chartsData="chartsData.statisticOrderNumber24Hours"></statisticOrderNumber24Hours>
            </div>
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderSaleMoney24Hours :chartsData="chartsData.statisticOrderSaleMoney24Hours"></statisticOrderSaleMoney24Hours>
            </div>
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderNumberRecent30Days :chartsData="chartsData.statisticOrderNumberRecent30Days"></statisticOrderNumberRecent30Days>
            </div>
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderSaleMoneyRecent30Days
                        :chartsData="chartsData.statisticOrderSaleMoneyRecent30Days"></statisticOrderSaleMoneyRecent30Days>
            </div>
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderNumberRecentMonthsOfYear
                        :chartsData="chartsData.statisticOrderNumberRecentMonthsOfYear"></statisticOrderNumberRecentMonthsOfYear>
            </div>
            <div style="margin-bottom: 10px; background-color: white;">
                <statisticOrderSaleMoneyRecentMonthsOfYear
                        :chartsData="chartsData.statisticOrderSaleMoneyRecentMonthsOfYear"></statisticOrderSaleMoneyRecentMonthsOfYear>
            </div>
        </div>
    </view>
</template>

<script>

    import statisticOrderNumber from './statisticOrderNumber.vue';
    import statisticOrderNumber24Hours from './statisticOrderNumber24Hours.vue';
    import statisticOrderNumberRecent30Days from './statisticOrderNumberRecent30Days.vue';
    import statisticOrderNumberRecentMonthsOfYear from './statisticOrderNumberRecentMonthsOfYear.vue';
    import statisticOrderSaleMoney from './statisticOrderSaleMoney.vue';
    import statisticOrderSaleMoney24Hours from './statisticOrderSaleMoney24Hours.vue';
    import statisticOrderSaleMoneyRecent30Days from './statisticOrderSaleMoneyRecent30Days.vue';
    import statisticOrderSaleMoneyRecentMonthsOfYear from './statisticOrderSaleMoneyRecentMonthsOfYear.vue';
    import {StoreReportService} from "@/dev/services/store-report.service";
    import {CommonUtil} from "@/dev/core/utils/common.util";

    export default {
        data() {
            return {
                chartsData: {
                    statisticOrderNumber: null,
                    statisticOrderSaleMoney: null,
                    statisticOrderNumber24Hours: null,
                    statisticOrderSaleMoney24Hours: null,
                    statisticOrderNumberRecent30Days: null,
                    statisticOrderSaleMoneyRecent30Days: null,
                    statisticOrderNumberRecentMonthsOfYear: null,
                    statisticOrderSaleMoneyRecentMonthsOfYear: null,
                },
                isShow: false
            }
        },
        components: {
            statisticOrderNumber,
            statisticOrderNumber24Hours,
            statisticOrderNumberRecent30Days,
            statisticOrderNumberRecentMonthsOfYear,
            statisticOrderSaleMoney,
            statisticOrderSaleMoney24Hours,
            statisticOrderSaleMoneyRecent30Days,
            statisticOrderSaleMoneyRecentMonthsOfYear,
        },
        onReady() {
            const _self = this;
            new StoreReportService().statisticStoreInfo({
                storeId: _self.globalVariable.userInfo.tbStore.id,
                prevStoreId: _self.globalVariable.userInfo.tbStore.id
            }).then(result => {
                console.log(result)
                Object.assign(_self.chartsData, CommonUtil.deleteNullAttrInObject(result));

                /*
                "LineA": {
                            "categories": ["2012", "2013", "2014", "2015", "2016", "2017"],
                            "series": [
                                {
                                    "name": "成交量A",
                                    "data": [35, 8, 25, 37, 4, 20]
                                },
                                {
                                    "name": "成交量B",
                                    "data": [70, 40, 65, 100, 44, 68]
                                },
                                {
                                    "name": "成交量C",
                                    "data": [100, 80, 95, 150, 112, 132]
                                }
                            ]
                        },
                 */

                _self.chartsData.statisticOrderNumber = {
                    "categories": ['未支付订单', '未发货订单', '已发货订单', '确认收货订单', '交易成功订单', '退款中订单', '退款完成订单', '取消订单'],
                    "series": [
                        {
                            "name": "订单数",
                            "data": [_self.chartsData.statisticOrderNumber['0'], _self.chartsData.statisticOrderNumber['1'], _self.chartsData.statisticOrderNumber['2'], _self.chartsData.statisticOrderNumber['3'], _self.chartsData.statisticOrderNumber['4'], _self.chartsData.statisticOrderNumber['5'], _self.chartsData.statisticOrderNumber['refunding'], _self.chartsData.statisticOrderNumber['6']]
                        },
                    ]
                };

                _self.chartsData.statisticOrderSaleMoney = {
                    "categories": ['未支付订单', '未发货订单', '已发货订单', '确认收货订单', '交易成功订单', '退款中订单', '退款完成订单', '取消订单'],
                    "series": [
                        {
                            "name": "销售额（单位/元）",
                            "data": [_self.chartsData.statisticOrderSaleMoney['0'], _self.chartsData.statisticOrderSaleMoney['1'], _self.chartsData.statisticOrderSaleMoney['2'], _self.chartsData.statisticOrderSaleMoney['3'], _self.chartsData.statisticOrderSaleMoney['4'], _self.chartsData.statisticOrderSaleMoney['5'], _self.chartsData.statisticOrderSaleMoney['refunding'], _self.chartsData.statisticOrderSaleMoney['6']]
                        },
                    ]
                };

                _self.chartsData.statisticOrderNumber24Hours = {
                    "categories": _self.chartsData.statisticOrderNumber24Hours.titleList,
                    "series": [
                        {
                            "name": "订单数=(待发货+已发货+确认收货+已完成)",
                            "data": _self.chartsData.statisticOrderNumber24Hours.valueList
                        },
                    ]
                };

                _self.chartsData.statisticOrderSaleMoney24Hours = {
                    "categories": _self.chartsData.statisticOrderSaleMoney24Hours.titleList,
                    "series": [
                        {
                            "name": "销售额=(待发货+已发货+确认收货+已完成)",
                            "data": _self.chartsData.statisticOrderSaleMoney24Hours.valueList
                        },
                    ]
                };

                _self.chartsData.statisticOrderNumberRecent30Days = {
                    "categories": _self.chartsData.statisticOrderNumberRecent30Days.titleList,
                    "series": [
                        {
                            "name": "订单数=(待发货+已发货+确认收货+已完成)",
                            "data": _self.chartsData.statisticOrderNumberRecent30Days.valueList
                        },
                    ]
                };

                _self.chartsData.statisticOrderSaleMoneyRecent30Days = {
                    "categories": _self.chartsData.statisticOrderSaleMoneyRecent30Days.titleList,
                    "series": [
                        {
                            "name": "销售额=(待发货+已发货+确认收货+已完成)",
                            "data": _self.chartsData.statisticOrderSaleMoneyRecent30Days.valueList
                        },
                    ]
                };

                _self.chartsData.statisticOrderNumberRecentMonthsOfYear = {
                    "categories": _self.chartsData.statisticOrderNumberRecentMonthsOfYear.titleList,
                    "series": [
                        {
                            "name": "订单数=(待发货+已发货+确认收货+已完成)",
                            "data": _self.chartsData.statisticOrderNumberRecentMonthsOfYear.valueList
                        },
                    ]
                };

                _self.chartsData.statisticOrderSaleMoneyRecentMonthsOfYear = {
                    "categories": _self.chartsData.statisticOrderSaleMoneyRecentMonthsOfYear.titleList,
                    "series": [
                        {
                            "name": "销售额=(待发货+已发货+确认收货+已完成)",
                            "data": _self.chartsData.statisticOrderSaleMoneyRecentMonthsOfYear.valueList
                        },
                    ]
                };

                _self.isShow = true;
            });
        },
        methods: {}
    }
</script>

<style>
</style>
